<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<?php
require_once('php_shared/session_to_db.php');

if( $_SERVER['REQUEST_METHOD'] == 'GET' )
{
	session_start();
	
	if( isset($_GET['friend_id'], $_SESSION['user_id']) )
	{
		if( $_SESSION['user_id'] != '' )
		{
			$db_man = new DbUtils();
			
			if( $db_man->connect() )
			{
				$f_uid = $db_man->set_var( $_GET['friend_id'] );
				$uid = $db_man->set_var( $_SESSION['user_id'] );
				$sql = "DELETE FROM friend WHERE (user_id=$uid AND friend_id=$f_uid AND accepted='0')";
				
				$db_man->query($sql);
				
				$db_man->close();
			}
		}
	}
	header("Location: messenger.php");
}
?>